home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / archivers / xfd / developer / sources / asm / cp.a < prev    next >
Text File  |  1999-06-14  |  3KB  |  132 lines

  1. *******************************************************
  2. **      XFD external decruncher for CP Cruncher      **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **  fixed by Georg Hörmannn in 1998 and SDI in 1999  **
  5. *******************************************************
  6.  
  7.         INCLUDE    "AINCLUDE:IncDirs.i"
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.         INCLUDE    "lvo.i"
  10.  
  11.         * head function for tests
  12. *        INCLUDE    "xfdExeHead.a"
  13.  
  14. ; xfdForeman structure MUST be first thing in all external decrunchers
  15.  
  16. ForeMan        moveq    #-1,d0        ;security
  17.         rts
  18.         dc.l    XFDF_ID        ;id
  19.         dc.w    1        ;version
  20.         dc.w    0
  21.         dc.l    0,0        ;private
  22.         dc.l    S_CP        ;first slave
  23.  
  24. **************************************************
  25.  
  26. ; xfdSlave structure: this one doesn't support data scanning
  27.  
  28. S_CP        dc.l    0        ;no more slaves
  29.         dc.w    2        ;version
  30.         dc.w    39        ;master version
  31.         dc.l    N_CP        ;name
  32.         dc.w    XFDPFF_DATA|XFDPFF_RECOGLEN|XFDPFF_USERTARGET
  33.         dc.w    0
  34.         dc.l    RB_CP        ;recog buffer
  35.         dc.l    DB_CP        ;decrunch buffer
  36.         dc.l    0        ;recog segment
  37.         dc.l    0        ;decrunch segment
  38.         dc.w    0,0
  39.         dc.l    12+2
  40.  
  41.         dc.b    "$VER: CP 2.0 (20.02.1999)",0
  42. N_CP        dc.b    "(CP) Data Cruncher",0
  43.         even
  44.  
  45. ;-------------------------------------------------
  46.  
  47. ; Recog buffer function: receives buffer + length in a0/d0
  48.  
  49. RB_CP        MOVEQ    #0,D0
  50.         CMP.W    #"CP",(A0)
  51.         BNE.B    .Exit
  52.         TST.B    4(A0)
  53.         BNE.B    .Exit
  54.         TST.B    8(A0)
  55.         BNE.B    .Exit
  56.         MOVE.L    8(A0),xfdrr_FinalTargetLen(A1)
  57.         MOVE.L    8(A0),xfdrr_MinTargetLen(A1)
  58.         MOVE.L    4(A0),xfdrr_MinSourceLen(A1)
  59.         MOVEQ    #1,D0
  60. .Exit        RTS
  61.  
  62. ;-------------------------------------------------
  63.  
  64. ; Decrunch buffer function: receives bufferinfo in a0
  65. ; This style requires xfdmaster.library V39
  66. DB_CP        MOVEM.L    D2-D7/A2-A6,-(A7)
  67.         MOVEA.L    A0,A4
  68.         MOVE.L    xfdbi_UserTargetBuf(A4),A1
  69.         MOVEA.L    A1,A5
  70.         ADDA.L    xfdbi_TargetBufSaveLen(A4),A5
  71.         MOVE.L    xfdbi_SourceBuffer(A4),A0
  72.  
  73.         LEA    $10(A0),A2
  74.         move.l    8(A0),D1
  75.         move.w    12(A0),D0
  76.         lea    (A0,D0.W),A3
  77.         move.w    14(A0),D0
  78.         lea    (A0,D0.W),A0
  79.         move.b    #$80,D3
  80. .decr1        move.b    (A2),D0
  81.         and.b    D3,D0
  82.         bne.s    .decr4
  83.         CMPA.L    A5,A1        * overrun check
  84.         BEQ.B    .Err
  85.         move.b    (A0)+,(A1)+
  86.         subq.l    #1,D1
  87. .decr2        ror.b    #1,D3
  88.         bpl.s    .decr3
  89.         addq.l    #1,A2
  90. .decr3        tst.l    D1
  91.         bne.s    .decr1
  92.         MOVEQ    #1,D0
  93. .End        MOVEM.L    (A7)+,D2-D7/A2-A6
  94.         RTS
  95.  
  96. .Err        MOVE.W    #XFDERR_CORRUPTEDDATA,xfdbi_Error(A4)
  97.         MOVEQ    #0,D0
  98.         BRA.B    .End
  99.  
  100. .decr4        move.b    (A3)+,D6
  101.         lsl.w    #8,D6
  102.         move.b    (A3)+,D6
  103.         move.w    D6,D7
  104.         andi.w    #$F000,D7
  105.         eor.w    D7,D6
  106.         bne.s    .decr5
  107.         move.w    #$1000,D6
  108. .decr5        movea.l    A1,A6
  109.         suba.w    D6,A6
  110.         rol.w    #4,D7
  111.         cmpi.w    #15,D7
  112.         bcs.s    .decr7
  113.         andi.w    #$FF,D6
  114. .decr6        move.b    (A3)+,D6
  115.         add.w    D6,D7
  116.         cmpi.b    #$FF,D6
  117.         beq.s    .decr6
  118. .decr7        andi.l    #$FFFF,D7
  119.         sub.l    D7,D1
  120.  
  121.         MOVE.L    A1,D6        * overrun check
  122.         ADD.L    D7,D6
  123.         CMPA.L    D6,A5
  124.         BLO.B    .Err
  125.  
  126.         subq.w    #1,D7
  127. .decr8        move.b    (A6)+,(A1)+
  128.         dbra    D7,.decr8
  129.         bra.b    .decr2
  130.  
  131.         END
  132.